/*
 * @Author: wfl
 * @LastEditors: wfl
 * @description: 多边形
 * @updateInfo:
 * @Date: 2021-12-08 10:35:19
 * @LastEditTime: 2021-12-08 14:07:43
 */
import * as Cesium from 'cesium';
export default function useReact(viewer: Cesium.Viewer) {
  const entry = viewer.entities.add({
    name: "polygon test",
    // 坐标配置
    polygon: {
      // 1.遵循测地线路径 GEODESIC
      // 2.不符合椭球表面的直线 NONE
      // 3.遵循rhumb或loxodrome路径 RHUMB
      arcType: Cesium.ArcType.RHUMB,
      // 1.只对地形进行分类 TERRAIN
      // 2.只有3D瓷砖将被分类 CESIUM_3D_TILE
      // 3.地形和3D瓷砖都将被分类 BOTH
      // classificationType: Cesium.ClassificationType.BOTH,

      // 指定该多边形将在距相机多远的距离处显示
      distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10.0, 2000000.0),
      hierarchy: {
        // 多边形至少需要三个点
        positions: Cesium.Cartesian3.fromDegreesArray([
          -108.0,
          42.0,
          -100.0,
          42.0,
          -104.0,
          40.0,
        ]),
        holes: []
      },
      // 高度
      extrudedHeight: 50000.0,
      // 材质
      // material: Cesium.Color.GREEN,
      // material: new Cesium.ColorMaterialProperty(Cesium.Color.fromRandom()),
      material: new Cesium.ImageMaterialProperty({
        image: '/cesiumAssets/img/arrow_1.png',
        repeat: new Cesium.Cartesian2(20, 50),
        color: Cesium.Color.YELLOW,
        transparent: true,
      }),
      // 闭合顶部
      closeTop: false,
      // 闭合底部
      closeBottom: false,
    },
  });

  return {
    entry
  };
}